// pages/myaccount/index.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    password:null ,//密码
    confirmpaw:null, //确认密码
    phone:null, //手机号
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  onpasWInput(e){
    let that = this;
    let password = e.detail.value;
    that.setData({
      password
    })
  },
  onconfirmPaw(e){
    let that = this;
    let confirmpaw = e.detail.value;
    console.log(e);
    that.setData({
      confirmpaw
    })
  },
  onphone(e){
    let that = this;
    let phone = e.detail.value;
    that.setData({
      phone
    })
  },

  /**立即注册**/
  onregistered(e){
    let that = this;
    let password = that.data.password;
    let confirmpaw = that.data.confirmpaw;
    let phone = that.data.phone;
    if (phone==null || !(/^1[34578]\d{9}$/.test(phone))) {
      wx.showToast({ title: '手机号填写错误', icon: 'loading', duration: 1500 }) 
    }else if(password==null || password.length <8){
      wx.showToast({icon: 'none', title: '密码至少8位',duration: 1500 })
    }else if(confirmpaw==null || password!=confirmpaw){ 
      wx.showToast({ title: '确认密码出错', icon: 'loading', duration: 1500 }) 
    }else{
      wx.showToast({ title: '注册成功', icon: 'success', duration: 2000 }) 
    }
    
    // else { 
    //   wx.showToast({ title: '注册成功', icon: 'success', duration: 2000 }) 
    // } 

    console.log(confirmpaw);
    console.log(phone);
  },

  /*返回*/
  navigateBack() {
    wx.navigateBack({
      delta: 1
    })
  },

})